package com.atguigu.ai.entity.vo;

import lombok.Data;
import org.springframework.ai.chat.messages.Message;

import java.io.Serializable;

import static org.springframework.ai.chat.messages.MessageType.ASSISTANT;
import static org.springframework.ai.chat.messages.MessageType.USER;

@Data
public class MessageVO implements Serializable {
    private String role;
    private String content;

    public MessageVO() {
    }

    public MessageVO(Message message) {
        switch (message.getMessageType()) {
            case USER -> role = USER.getValue();
            case ASSISTANT -> role = ASSISTANT.getValue();
            default -> role = "";
        }
        this.content = message.getText();
    }
}
